<!DOCTYPE html>
<html>
<head>
	  <meta charset="utf-8">
	  <title></title>
	  <meta name="renderer" content="webkit">
	  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	  <link rel="stylesheet" href="../layui/css/layui.css"  media="all">
</head>
<body>

	<div class="layui-fluid">
		<div class="layui-row">
			<p>
				<div class="layui-inline">日期：</div>
				<div class="layui-inline">
					<input type="text" class="layui-input" style="width:300px;" id="date">
				</div>
			</p>
		</div>
		<div class="layui-row">
			<table id="demo" layui-filter="test"></div>
		</div>
	</div>

</body>
<script src="../layui/layui.all.js"></script>
<script type="text/javascript" src="../../disanfanglogin/vendor/jquery/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="../js/linxi.js"></script>
<script type="text/javascript">
	$(document).ready(function(){

    
    linxi.loginYanZheng(function(userInfo){

      
      if(userInfo.data.user_root.Agent_data_report==0){
            var layer = layui.layer;
            layer.msg('非法闯入')
            return;
      }

      var  kefuFileds = [ //表头

             {field: 'staffName', title: '客服姓名',  sort: true, fixed: 'left'}
             ,{field: 'callCount', title: '拨打数量',  sort: true, fixed: 'left'}
             ,{field: 'pickUpCount', title: '接通数量',  sort: true, fixed: 'left'}
             ,{field: 'pickUpRate', title: '接通率',  sort: true, fixed: 'left',templet:function(d){return d.pickUpRate + '%'}}
             ,{field: 'callTotalTime', title: '总通话时长',  sort: true, fixed: 'left'}
             ,{field: 'effectiveCallTotalTimeAvg', title: '有效通话平均时长',  sort: true, fixed: 'left'}
             ,{field: '', title: '派客情况',  sort: true, fixed: 'left',templet:function(d){

             	var value = $('#date').val()

             	var dateRange = value.split(' - ')

          		dateRange = dateRange[0].split(' ')[0]+"&endDate="+dateRange[1].split(' ')[0]

	      		var par={}

	      		$.ajax({

	      			url:'../api/api.php?type=getKeFuFenPeiCount&followerName='+d.staffName+'&starDate='+dateRange,
	      			async:false,
	      			success: function(data){

	                    data = JSON.parse(data).data[0]

	      				par = data
	      				
                             
                    }
	      		})
	
	      		if(par!==undefined){

	      			if(par.zhuandan>=6){

	      				return "<div class=\"layui-badge \">派：" + par.COUNT + "</div> <div class=\"layui-badge\">转：" + par.zhuandan + "</div> <div class=\"layui-badge\">NO：" + par.pass + "</div>"

	      			}else{

	      				return "<div class=\"layui-badge layui-bg-cyan\">派：" + par.COUNT + "</div> <div class=\"layui-badge layui-bg-cyan\">转：" + par.zhuandan + "</div> <div class=\"layui-badge layui-bg-cyan\">NO：" + par.pass + "</div>"

	      			}

	      			
	      		}else{
	      			return "<div class=\"layui-badge layui-bg-cyan\">无</div>"
	      		}
	      			
             }}
      ]

      var kefuapiName = 'baobiao'

      var kefustarDate = new Date().Format('yyyy-MM-dd')

      var kefuendDate = new Date().Format('yyyy-MM-dd')

      kefuele = '#demo'

      // createTable(kefuapiName,kefustarDate,kefuendDate,kefuele,kefuFileds)
      linxi.createTable({type:kefuapiName,starDate:kefustarDate,endDate:kefuendDate},kefuele,kefuFileds)


      linxi.laydate('#date',function(value, date, endDate){

          var dateRange = value.split(' - ')

          dateRange = dateRange[0].split(' ')[0]+"&endDate="+dateRange[1].split(' ')[0]

          linxi.table.reload('demo', {
                url: '../api/api.php?type=baobiao&starDate='+dateRange
          });


          var canshu={type:'getKeFuFenPeiCount',starDate:dateRange[0],endDate:dateRange[1],followerName:'张宏杨'}

	      $.get('../api/api.php?type=getKeFuFenPeiCount&followerName=张宏杨&starDate='+dateRange,function(data){

	      		data = JSON.parse(data).data

	      		console.log(data)
	      })

      })








    })
})
</script>
</html>